package com.lgCore.model;/**
 * Created by by on 2020/11/7 15:34
 */

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

/**
 * zk 配置信息
 *
 * @program: sxreader_rpc
 * @author: ligang
 * @create: 2020-11-07 15:34
 */
@Data
@Getter
@Setter
public class BaseConnectionInfo implements Serializable {
    /**
     * zk连接地址
     */
    public static String connectionString;

    /**
     * 根目录
     */
    public static String zkRootPath = "serviceRpc";

    /**
     * 会话超时时间（毫秒）
     * 大于 2*tickTime 和 小于20*tickTime
     * <p>
     * tickTime：4000
     */
    public static int sessionTimeoutMs = 10 * 4000;
    /**
     * 连接超时时间（毫秒）
     */
    public static int connectionTimeoutMs = 10 * 4000;
    /**
     * 睡眠时间（毫秒）
     */
    public static int baseSleepTimeMs = 2000;

    /**
     * 最大睡眠时间（毫秒）
     */
    public static int maxSleepTimeMs = 60 * 1000 * 5;


    /**
     * 重试次数（一直重试）
     */
    public static int maxRetries = 3000;

    public static String getConnectionString() {
        return connectionString;
    }

    public static String getZkRootPath() {
        return zkRootPath;
    }

    public static int getSessionTimeoutMs() {
        return sessionTimeoutMs;
    }

    public static int getConnectionTimeoutMs() {
        return connectionTimeoutMs;
    }

    public static int getBaseSleepTimeMs() {
        return baseSleepTimeMs;
    }

    public static int getMaxRetries() {
        return maxRetries;
    }

    public static void setConnectionString(String connectionString) {
        BaseConnectionInfo.connectionString = connectionString;
    }

    public static void setZkRootPath(String zkRootPath) {
        BaseConnectionInfo.zkRootPath = zkRootPath;
    }

    public static void setSessionTimeoutMs(int sessionTimeoutMs) {
        BaseConnectionInfo.sessionTimeoutMs = sessionTimeoutMs;
    }

    public static void setConnectionTimeoutMs(int connectionTimeoutMs) {
        BaseConnectionInfo.connectionTimeoutMs = connectionTimeoutMs;
    }

    public static void setBaseSleepTimeMs(int baseSleepTimeMs) {
        BaseConnectionInfo.baseSleepTimeMs = baseSleepTimeMs;
    }

    public static void setMaxRetries(int maxRetries) {
        BaseConnectionInfo.maxRetries = maxRetries;
    }

    public static void setMaxSleepTimeMs(int maxSleepTimeMs) {
        BaseConnectionInfo.maxSleepTimeMs = maxSleepTimeMs;
    }

    public static int getMaxSleepTimeMs() {
        return maxSleepTimeMs;
    }
}
